package com.wanjia.order.server.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wanjia.order.server.entity.Users;
import com.wanjia.order.server.mapper.UsersMapper;
import com.wanjia.project.commons.dto.ResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UsersController {
    @Autowired
    private UsersMapper usersMapper;
    @GetMapping("/verifyName")
        public ResultDTO verifyName(String userName){
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_name",userName);
        Users users = usersMapper.selectOne(queryWrapper);
        if(users==null){
            return new ResultDTO(400,"用户名不存在",null);
        }else {
            return new ResultDTO(200,"成功",users.getUserId());
        }
    }
}
